<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=9">
        <link rel="stylesheet" href="<%=basePath %>css/cssreset.css">
        <link rel="stylesheet" href="<%=basePath %>css/yifa.css">
        <link rel="stylesheet" href="<%=basePath %>css/daohang.css">
        <script src="<%=basePath %>js/jquery-1.11.1.min.js"></script>
        <script src="<%=basePath %>js/menu.js"></script>
        <script type="text/javascript" src="<%=basePath %>salejihui/My97DatePicker/WdatePicker.js"></script> 
        <style>
        	a{
        		text-decoration:none;
        		color:#708dac;
        	}
        	.psxa{
			color:#708dac;
			width:100%;
			line-height:23px;
			text-align: center;
			margin-top:27px;
			font-family: '微软雅黑';
			cursor:pointer;
			font-size:16px;
		}
		.ims{
			position:relative;
			top:4px;
			right:22px;
		}
        </style>      
    </head>
    <body>
    	<div class="headers">
    		<p class="pa">客户管理系统CRM</p>
    		<p class="rights">
	    		<img src="<%=basePath %>images/user.png" alt="">
	    		${staff.staff_name}
	    		<button onclick="ind()"></button>
    		</p>
    	</div>
    	<section>
    		<ol class="lefts">
    			<li class="pb">
    				<img src="<%=basePath %>images/Users and permissions.png" alt="">
    				用户和权限
    				<img src="<%=basePath %>images/button (2).png" alt="">
    				<div class="div1">
    					<p class="zcd" id="zcd1"><a href="<%=basePath %>html/setupgroups.html">角色管理</a></p>
						<p class="zcd" id="zcd2"><a href="<%=basePath %>html/bumenyonghuguanli.html">部门/用户管理</a></p>
    				</div>
    			</li>
    			<li class="px">
    				<img src="<%=basePath %>images/canshu.png" alt="">
    				业务参数和设定
    				<img src="<%=basePath %>images/button (2).png" alt="">
    				<div class="div1">
    					<%-- <p class="zcd" id="zcd1" name="ppa"><a href="<%=basePath %>tradeManage/select.action">行业管理</a></p>
                        <p class="zcd" id="zcd2" name="ppa"><a href="<%=basePath %>compactGenre/select.action">合同类型</a></p>
                        <p class="zcd" id="zcd1" name="ppa"><a href="<%=basePath %>rank/select.action">客户级别</a></p> --%>
                         <p class="zcd" id="zcd2" name="ppa"><a href="<%=basePath %>rank/select.action">申请性质</a></p> 
                        <p class="zcd" id="zcd2" name="ppa"><a href="<%=basePath %>salestage/select.action">产品类别</a></p> 
                        <p class="zcd" id="zcd2" name="ppa"><a href="<%=basePath %>record/select.action">来源渠道</a></p>
    				</div>
    			</li>
    			<li class="py">
    				<img src="<%=basePath %>images/liucheng.png" alt="">
    				流程管理
    				<img src="<%=basePath %>images/button (2).png" alt="">
    				<div class="div1">
    					<p class="zcd" id="zcd1"><a href="<%=basePath %>approveRole/select.action">审批流程管理</a></p>
    					<p class="zcd" id="zcd1"><a href="<%=basePath%>approve/count.action?pageSize=2" >已审批流程查看</a></p>
    				</div>
    			</li>
    			<li class="pxa" style="color:#fff;">
    				<img src="<%=basePath %>images/gonggao.png" width="18px">
    				公告管理&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    			</li>
    			 <li class="pxaa">
                    <img src="../images/kehu (1).png" alt="">
                    		资源开发
                    <img src="../images/button (2).png" alt="">
                    <div class="div1">
                        <p class="zcd" id="zcd1"><a href="<%=basePath %>client/weifencount.action?zhuizong=0">用户开发</a></p>
                        <p class="zcd" id="zcd2"><a href="../client/findByAllForAgent.action?start=1">代理开发</a></p>
                    </div>
                </li> 
                <%-- <li class="pxas">
    				<img src="../images/kehuzilao.png" alt="">
    				客户资料
    				<img src="../images/button (2).png" alt="">
    				<div class="div1" >
    					<p class="zcd" id="zcd1"><a href="<%=basePath%>client/findByAllData.action?start=1">用户资料</a></p>
						<p class="zcd" id="zcd2"><a href="<%=basePath%>client/findByAllData.action">代理资料</a></p>
    				</div>
    			</li> --%>
    			<li class="psxa">
    				<img src="../images/operation-management.png" alt="" width="16px" class="ims">
    				<a href="<%=basePath %>Operate/count1.action">运营管理&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
    			</li>
    		</ol>
    		<div class="righta">
    			<div class="smalls">
    				<p class="pj">公告管理</p>
    				<div class="pjs">
    					<div class="pjss">
    						<p class="pjssa"><a href="<%=basePath %>html/gongao.jsp" style="color:#555;">发布公告</a></p>
    						<p class="pjssb"><a href="<%=basePath %>html/yifa.jsp" style="color:#fff;">已发布公告</a></p>
    					</div>
    					<table id="tableform">
    						<tbody>
    							<tr class="trs">
    								<td>内容</td>
    								<td>发布时间<input type="text" id="dates" class="Wdate" onClick="WdatePicker()"><input type="button" value = "查询" onclick="findByDate()"></td>
    								<td></td>
    								<td></td>
    							</tr>
    							<c:forEach items="${list}" var="list" varStatus="status">
    							<tr>
    								<td>${list.notice_text}</td>
    								<td><fmt:formatDate value="${list.notice_releaseDate}" type="both" pattern="yyyy-MM-dd"/></td>
    								<td><img src="<%=basePath %>images/edit.png" alt="" id="${status.index+1}" onclick="bian(id,${list.notice_id})"></td>
    								<td><img src="<%=basePath %>images/delete.png" alt="" id="${list.notice_id}" class="imgx" onclick="deletenotice(${list.notice_id})"></td>
    							</tr>
    							</c:forEach>
    						</tbody>
    					</table>
    				</div>
    			</div>
    		</div>
    	</section>
    	<div class="asd" id="asd">
    		<p>编辑内容<img src="<%=basePath %>images/guanbi.png" alt=""></p>
    		<input type="hidden" id="nid">
    		<form action="" method="post" onsubmit="return textas()">
    			<p><span>内容&nbsp;:</span><textarea name="" id="texts" cols="30" rows="10"></textarea></p>
    			<p><input type="button" value="确定" onclick = "update()"></p>
    		</form>
    	</div>
    	<div class="smallas"></div>
    </body>
    <script>
    	/*$('.imgs').click(function(event) {
    		$('.asd').css('display', 'block');
    		$('.smallas').css('display', 'block');
    	});*/
    	function deletenotice(id){
    		  		
    	  	$.ajax({
    			type:"post",
    			url:"<%=basePath %>notice/deleteById.action",
    			data:{id:id},
    			success:function(data){
    				alert(data);
    				location.href="<%=basePath %>notice/page.action";
    			},
    			error:function(e){
    				alert("发生未知错误请刷新页面");
    			}

       		 });
    	}
    	
    	
    	function findByDate(){
    		var dates = $("#dates").val();
    		if(dates == ""){
    			return;
    		}
    		location.href="../notice/findByDate.action?notice_releaseDate="+dates;
    	  	<%-- $.ajax({
    			type:"post",
    			url:"<%=basePath %>notice/findByDate.action",
    			data:{notice_releaseDate:$('#dates').val()},
    			success:function(data){
    				//alert(data);
    				location.href=<%=basePath%>+"notice/page.action";
    			},
    			error:function(e){
    				alert("发生未知错误请刷新页面");
    			}

       		 }); --%>
    	}
    	
    	
    	
    	
    	
    	
    	
    	function update(){
    		
	    		$.ajax({
					type:"post",
					url:"<%=basePath %>notice/update.action",
					data:{
						notice_text:$('#texts').val(),
						notice_id:$('#nid').val()
						},
					success:function(data){
						
						location.href="<%=basePath %>notice/page.action";
					},
					error:function(e){
						alert("发生未知错误请刷新页面");
					}	
		   		 });
    		
    		}

    	
    	$('.asd>p>img').click(function(event) {
    		$('.asd').css('display', 'none');
    		$('.smallas').css('display', 'none');
    	});
    	
    	
    	function bian(id,nid){
    	/*var imga=document.getElementById('imgs');*/
		//获取表格中的一行数据  
		var neirong= document.getElementById("tableform").rows[id].cells[0].innerText;
		
		//向模态框中传值  
		$('#texts').val(neirong);
		$('#nid').val(nid);
    		var asda=document.getElementById('asd');
    		asda.style.display='block';
    		/* $.ajax({
    			url:'1.json',
    			type:'post',
    			data:{id:texts},
    			success:function(data){
    				$('#texts').val(data[0].text);
    			}
    		}) */
    	}
    	var texta=document.getElementById('texts');
    	function textas(){
    		var txta=texta.value;
    		var pat=/\s/;
	    	var val=true;
	    	if(txta==''||pat.test('txta')){
	    		alert('请输入公告内容！');
	    		val=val&&false;
	    	}
	    	return val;
    	}
    	function ind(){
        	window.location.href= "../notice/findByAll.action";
        }
    </script>
</html>